using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace JumpBall_2
{
    public class CameraControll : MonoBehaviour
    {
        public Camera[] cameraArrays;

        public int index;


        void Update()
        {
            if (Input.GetKeyDown(KeyCode.Space))
            {
                index = (index + 1) % cameraArrays.Length;
                SwitchCamera(index);
            }
        }

        void SwitchCamera(int index)
        {
            if (index < 0 && index >= cameraArrays.Length)
            {
                return;
            }
            foreach (Camera camera in cameraArrays)
            {
                camera.enabled = false;
            }
            cameraArrays[index].enabled = true;
        }
    }
}